/**
 * 
 */
package com.et114.components.compass;

import java.util.Date;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.compass.gps.CompassGps;

import com.et114.core.control.IAppInitBean;

/*
 * @author guanhw
 */
public class CompassIndexBuilder implements IAppInitBean{
	protected Log logger = LogFactory.getLog( this.getClass( ) );
	private CompassGps	compassGps;
	private List < ICompass > compassVos ; 
	
	public CompassGps getCompassGps ( ) {
		return compassGps;
	}
	public List < ICompass > getCompassVos ( ) {
		return compassVos;
	}
	public void setCompassVos ( List < ICompass > compassVos ) {
		this.compassVos = compassVos;
	}

	public void setCompassGps ( CompassGps compassGps ) {
		this.compassGps = compassGps;
	}

	public synchronized void buildIndex ( ) {
		try {
			compassGps.index ( );
			if ( compassVos != null ) 
				for ( ICompass compass : compassVos )  {
					compass.setUpdateTimeFrom ( new Date( ) ) ;
					logger.info ( "compass:::" + new Date( ) ) ;
				}
		}
		catch ( Exception ex ) {
			logger.error ( ex.getMessage ( ) ,ex ) ; 
		}
	}
	
	public void init ( ) throws Exception {
		// TODO Auto-generated method stub
		buildIndex ( ) ;
	}
	
}